<?php

namespace Modules\Card\Http\Controllers\Client\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use Modules\Card\Entities\Card;

use Validator;
use ThrowException;
use Auth;

class UserCardController extends Controller
{
    public function index(Request $req)
    {
        $rule = [
        ];

        Validator::make($req->all(), $rule)->fails() && ThrowException::BadRequest();

        $user = Auth::requireLoginUser();

        $cards = Card::get();

        $info = [
            'show_box_card' => [
                'score_price' => @$cards->where('type', 'show_box')->first()->score_price,
                'is_show' => @$cards->where('type', 'show_box')->first()->status,
                'my_balance' => $user->card_asset('show_box')->balance,
            ],
            'exclude_box_card' => [
                'score_price' => @$cards->where('type', 'exclude_box')->first()->score_price,
                'is_show' => @$cards->where('type', 'exclude_box')->first()->status,
                'my_balance' => $user->card_asset('exclude_box')->balance,
            ]
        ];

        return $info;
    }
}
